java - 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 的文档:
解决方案
这种情况下有一种休眠方言,称为 org.hibernate.spatial.dialect.postgis.PostgisDialect
这能够使用 JPA 将几何图形直接加载和存储到带有 PostGis 的 Postgres DB。
在http://www.hibernatespatial.org/documentation/02-Tutorial/01-tutorial4/您可以找到使用它的教程。
推荐阅读
- android - 在drawable中添加和定位drawable
- python - 计算 django 电子商务中的订单总额
- class - 在另一个类 C++ 的方法中创建类对象
- python - 如何使用 python ssl 模块获取证书的签名密钥长度
- arrays - 从数组中的每个文件中读取行——条件永远不会成功
- php - 完整性约束违规:1048 laravel Laravel
- sql-server - 使用变量调试 CTE?
- swift4 - swift4 UISwipeGestureRecognizer Viewcontroller 带有大标题和单元格不起作用
- ansible - Ansible 在没有密码文件的情况下无法运行
- javascript - jQuery Transverse Up(通过 sibs、parents、grandPs 等)直到找到 Element 的第一个实例