Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

173
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda