0

so geoserver shows me a red dot within a blue polygon, i thought postgis can tell me that fact by query. i tried the following statements without success, can anyone tell me what i did wrong?

select

    -- within on geometry with srid
    ST_Within(
        st_geometryfromtext('point(9.05 52.25)', 4326)
        ,
        st_geometryfromtext('POLYGON((9 52,9.2 52,9.1 52.1066357,9 52))', 4326)
    ),

    -- within on geometry with srid, swap arguments
    ST_Within(
        st_geometryfromtext('POLYGON((9 52,9.2 52,9.1 52.1066357,9 52))', 4326)
        ,
        st_geometryfromtext('point(9.05 52.25)', 4326)
    ),

    -- within on geometry without srid
    ST_Within(
        st_geometryfromtext('point(9.05 52.25)')
        ,
        st_geometryfromtext('POLYGON((9 52,9.2 52,9.1 52.1066357,9 52))')
    ),

    -- within on geometry without srid, swap arguments
    ST_Within(
        st_geometryfromtext('POLYGON((9 52,9.2 52,9.1 52.1066357,9 52))')
        ,
        st_geometryfromtext('point(9.05 52.25)')
    ),

    -- contains on geometry with srid
    ST_Contains(
        st_geometryfromtext('point(9.05 52.25)', 4326)
        ,
        st_geometryfromtext('POLYGON((9 52,9.2 52,9.1 52.1066357,9 52))', 4326)
    ),

    -- contains on geometry with srid, swap arguments
    ST_Contains(
        st_geometryfromtext('POLYGON((9 52,9.2 52,9.1 52.1066357,9 52))', 4326)
        ,
        st_geometryfromtext('point(9.05 52.25)', 4326)
    ),

    -- intersects on geography
    ST_Intersects(
        st_geographyfromtext('point(9.05 52.25)')
        ,
        st_geographyfromtext('POLYGON((9 52,9.2 52,9.1 52.1066357,9 52))')
    ),

    -- intersects on geography, swap arguments
    ST_Intersects(
        st_geographyfromtext('POLYGON((9 52,9.2 52,9.1 52.1066357,9 52))')
        ,
        st_geographyfromtext('point(9.05 52.25)')
    )
  • 1
    perhaps it isn't in the polygon :) – janechii Oct 27 '14 at 15:08
6

Yup... it isn't in the polygonoutside

By the way, you can simply visualize WKT from QGIS using QuickWKT plugin. That way you can do sanity check like this one.

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.