I'm trying to serve a view of my table after passing a GeoJSON polygon.

Te idea is get all the points inside my polygon passed as GeoJSON.

For this, I've created new SQL view, and a query:

select p.id, p.nombre
from points p, (select 1 as id, st_setSRID(st_GeomFromGeoJSON(%polygon%), 4326) as geom) as pol
where st_within(p.geom, pol.geom)

where polygon is the parameter I want to pass.

I'm getting the error ERROR: unexpected end of data (at offset 0) when I'm trying to save the query in GeoServer. The query is tested in PostGIS and running ok.

Any Idea what could be wrong?

  • what is the default value of polygon? – Ian Turton Jul 24 at 9:58
  • I've passed '' (two single quotes) as default value in geoserver. What should it be? – Pablo Pardo Jul 24 at 10:18
  • 1
    something that st_geomfromgeomjson can parse into a polygon – Ian Turton Jul 24 at 10:58

Fixed passing a 'sample' geoJSON as default value.

{ "type": "Polygon", 
"coordinates": [
        [ -4.573988468717024, 40.729307763884464 ],
        [ -2.687283913980384, 40.825389940283088 ],
        [ -2.634875454126589, 40.065467272403055 ],
        [ -4.268272452903218, 39.855833432987872 ],
        [ -4.573988468717024, 40.729307763884464 ] 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.