Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

168
Views
Jooq and postGIS

I am trying to get Jooq working with GIS queries and found some samples on SO. I have a question regarding one of the samples. I found the following function which builds a Polygon (How to select points within polygon in PostGIS using jOOQ?). Something like:

public static Field<?> stPolygon(Field<?> geom, int value) {
    return DSL.field("ST_Polygon({0}, {1})", Object.class, geom, DSL.val(value));
}

I am trying to figure out how I can use this to build a polygon field from GIS coordinates (specified as doubles as a list of [latitude, longitude])

After that, if I want to select records where some column (point) lies within this polygon, how can I create my comparison operator. Would the field.in function work fine for such needs?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You cannot use the IN predicate to check if a geometry is "in" another geometry. You ahve to use the spatial predicates for that, instead. For example:

select st_contains(
  st_makepolygon(st_makeline(array[
    st_point(0, 0), 
    st_point(0, 1), 
    st_point(1, 1), 
    st_point(1, 0), 
    st_point(0, 0)
  ])),
  st_point(0.5, 0.5)
)

Inspiration taken from this question. If you have a table containing geometries for your points, you can also aggregate the points to an array like this:

select st_contains(
  st_makepolygon(st_makeline(array_agg(points.point))), 
  st_point(0.5, 0.5)
)
from points

Built in support starting from jOOQ 3.16

Starting from jOOQ 3.16, there's built-in GIS support in the commercial editions of jOOQ. Some natively supported functions can be seen in the manual:

  • Spatial functions
  • Spatial predicates
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!