如何解决Java - 如何将 gml 数据存储到 postgres 数据库使用 postgis
我想存储在我的数据库中:
示例数据:
ST_GeomFromGML('
<gml:Linestring srsName="epsg:4269">
<gml:coordinates>
-71.16028,42.258729 -71.160837,42.259112 -71.161143,42.25932
</gml:coordinates>
</gml:Linestring>');
我在条目中创建了一个带有 2 个参数的 API(字符串 ID 和几何形状):
{
"id": "string","shape": {
"envelope": {},"factory": {
"coordinateSequenceFactory": {},"precisionModel": {
"scale": 0
}
},"srid": 0,"userData": {}
}
}
我的模型:
Entity
@Table(name = "test",schema = "aaa")
public class rectangle {
@Id
@Column(name = "id",length = 32)
private String id;
@Column(name = "shape")
private Geometry shape;
public rectangle() {
}
public rectangle(String id,Geometry shape) {
this.id = id;
this.shape = shape;
}
如何将我的示例日期解析到我的数据库?
找到关于 st_GeomFromGml 的文档:
https://postgis.net/docs/ST_GeomFromGML.html
解决方法
这种情况下有一种休眠方言,称为 org.hibernate.spatial.dialect.postgis.PostgisDialect
这能够使用 JPA 将几何图形直接加载和存储到具有 PostGis 的 Postgres 数据库。
在 http://www.hibernatespatial.org/documentation/02-Tutorial/01-tutorial4/,您可以找到使用它的教程。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。