最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

postgresql - Error using Postgres PostGIS unnest function with list of WKT strings using SpringBoot repo - Stack Overflow

programmeradmin1浏览0评论

My spring boot query looks like this:

@Query(value = "WITH input_points AS (SELECT ST_GeomFromText(unnest(:locations), :srid) AS geom)" + "SELECT ST_AsText(ip.geom) AS point_wkt FROM area_of_responsibility p "+ " JOIN input_points ip ON ST_Contains(p.shape, ip.geom) WHERE p.id = :id", nativeQuery = true)

List<String> findLocationsWithinZone(@Param("id") long id, @Param("locations") List<String> locations, @Param("srid") int srid);

It looks up a table "area_of_responsibility" for a polygon geometry that matches the given ID and will test the list of supplied points, using PostGIS function ST_Contains, if they are within the polygon. It then returns the points that match. When I debug what I am sending, it seems right. The id matches an id in the table, the srid is 4326 and the list of strings contains 2 strings that look like this (this the result when using WKTWriter from JTS using a point that has a z-coordinate): "POINT Z(-76.6 39.75 0)" "POINT Z(-79.6 39.75 0)"

I am getting an exception: SqlExceptionHelper : ERROR: function unnest(character varying, character varying) does not exist Hint: No function matches the given name and argument types. You might need to add explicit type casts. Position: 46

What am I doing wrong? I understand from looking up the error, unnest is complaining that it is getting a string and not an array, but it is a list of strings. I am pretty much a newbie at all of this.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论