MySQL supports using ST_PointFromText to construct a point with an SRID,

  • ST_PointFromText(wkt[, srid [, options]])

    Constructs a Point value using its WKT representation and SRID.

This assumes the input is Well-Known Text (WKT). How do I construct a point with latitude and longitude as doubles (or floating point types).

有帮助吗?

解决方案

MySQL 8.0+

MySQL supports Point(x,y) which is a GIS function that constructs a point. With MySQL 8.0 and newer, you can further assign an SRID to that point with ST_SRID(srid)

SELECT ST_SRID( Point(0,0), 4326);

This is a relatively new feature implemented in MySQL 8.0 with #WL8543. MariaDB does not support it.

In PostGIS, you would use,

SELECT ST_SetSRID( ST_MakePoint(0,0), 4326);

In MariaDB, your only option is,

ST_PointFromText(wkt[, srid [, options]])
许可以下: CC-BY-SA归因
不隶属于 dba.stackexchange
scroll top