It seems like besides using WKT and the GeomFromText function, MySQL support an other method of creating geometries. The function POINT() is used in the examples in the documentation, but I can not find where the function itself is documented.

This one is pretty straightforward, but I wonder if there are any other functions which can be used as well, instead of parsing WKT strings.

有帮助吗?

解决方案

MySQL has a spacial data type POINT. It's a type that encapsulates an x and y value pair to represent a coordinate in some space.

You can create a table with a column of that type via:

CREATE TABLE my_table (pt POINT);

For every spacial type there's a "constructor" function(s) to create a value of that type. For example, Point(x,y) - it returns a value of type POINT to be stored in the db, used in another function, etc:

INSERT INTO my_table (pt) VALUES (Point(1,2));

The docs that cover the functions for creating values of these types (incl. the Point() function) can be found at Creating spacial values and the section of the manual that it's in covers spacial types in general.

其他提示

POINT is not a function, it's a data type.

You use it like POINT(100, 20) to give you a coordinate of x = 100, y = 20.

It is documented at 12.16.2.3 Class Point:

A Point is a geometry that represents a single location in coordinate space.

Point Examples

Imagine a large-scale map of the world with many cities. A Point object could represent each city.

On a city map, a Point object could represent a bus stop.

This is where MySQL documents Point class.

A Point is a geometry that represents a single location in coordinate space.

It is documented here under title 12.16.5 MySQL-Specific Functions That Create Geometry Values

If you need to understand this constructor function and other information on Spatial Type in MySQL, follow my article on Medium Playing with Geometry/Spatial Data Types in MySQL

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top