创建空间对象表:
create table t_point (
id VARCHAR(36) not null,
name VARCHAR(200) null,
lonlat GEOMETRY null,
createTime TIMESTAMP null,
constraint PK_T_POINT primary key (id)
);
office对象:
private Geometry lonlat;
获取经纬度:
Geometry officelatlon = office.getLonlat();
Point officeP = (Point)officelatlon;
double officeLon = officeP.getX();
double officeLat = officeP.getY();
插入空间点:
INSERT INTO geometry_data (name,addr,geom) VALUES (?,?,'POINT(116.3908 39.92549)')
2点之间的距离:
st_distance_sphere(ST_MakePoint("+lonlat+"),lonlat)
查询点在面内:
SELECT id,name,addr,ST_AsText(ST_GeomFromText(geom)) FROM geometry_data WHERE 1=1
AND name like '私%建%' AND addr like '%中%' AND ST_Within
(geom,ST_GeomFromText('POLYGON((116.38272 39.90706,116.38350614443412 39.95209818446651))'))
LIMIT 10 OFFSET 0