I am using the following query to create a GeoJson response:
SELECT json_build_object(
'type', 'FeatureCollection',
'features', jsonb_agg(feature)
)
FROM (
SELECT json_build_object(
'type', 'Feature',
'id', id,
'geometry', ST_AsGeoJSON(ST_ForcePolygonCW(wkb_geometry))::json,
'properties', to_jsonb(row) - 'id' - 'wkb_geometry'
) AS feature
FROM (SELECT * FROM gis_states LIMIT 1) AS row
) AS features
The resulting data-set (https://pastebin.com/hvFQXUTr) does not validate at http://geojsonlint.com, even though I am using ST_ForcePolygonCW:
Line 1: Polygons and MultiPolygons should follow the right-hand rule
Any suggestions on how to fix this?