将几何图形插入到后 GIS



嗨,我正在使用postgresql和node.js作为后端。 我想从前端将点插入数据库,但出现错误 ">值对于类型字符变化(50(来说太长" 我正在使用的这个插入查询

insert into public.fat (name,splitter, geom) 
values ($1, $2, ST_GeomFromText('POINT($3)'))", [name,geom])

以下是用于向数据库添加点的 ArcGIS API 的前端代码

var point = {
type: "point", 
longitude: -49.97,
latitude: 41.73
};
var markerSymbol = {
type: "simple-marker", 
color: [226, 119, 40],
outline: {
color: [255, 255, 255],
width: 2
}
};
var pointGraphic = new Graphic({
geometry: point,
});
async function postData(url = 'http://localhost:8080/post', data = {name:'rafy', geom:point}) {
const response = await fetch(url, {
method: 'POST', 
mode: 'cors', 
cache: 'no-cache', 
credentials: 'same-origin', 
headers: {
'Content-Type': 'application/json'
},

如果要插入的列结构中有字符限制,则会出现错误。 您必须增加表中列的字符限制或出现变量的错误 $1::字符变化(50(

最新更新