Problem with query using ST_Dwithin

From: Nick <nick(dot)uebelhor(at)noaa(dot)gov>
To: pgsql-general(at)postgresql(dot)org
Subject: Problem with query using ST_Dwithin
Date: 2010-01-29 00:32:56
Message-ID: 6dffe58d-6637-4e03-bc7a-5d4d4d5863a7@a17g2000pre.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

The following query's all work fine,

select distinct zoa_metar_xml.stn_id, zoa_metar_xml.metar_txt,
zoa_metar_xml.time, zoa_metar_xml.flt_cat, zoa_metar_xml.cld_cvr,
zoa_metar_xml.cld_base, zoa_metar_xml.lonlat, zoa_metar_xml.geom from
zoa_metar_xml;

select distinct id, kml, type, min_hgt, max_hgt from
zoa_sectors_basetop where zoa_sectors_basetop.id='$i' and
(zoa_sectors_basetop.type = 'LO' or zoa_sectors_basetop.type='HILO');

select distinct zoa_sectors_basetop.id, west_pirep_xml.raw_text,
west_pirep_xml.cld_cvr, west_pirep_xml.cld_base,
west_pirep_xml.cld_top, west_pirep_xml.altitude, west_pirep_xml.time,
west_pirep_xml.acft_type, zoa_sectors_basetop.max_hgt,
zoa_sectors_basetop.min_hgt, zoa_sectors_basetop.type,
west_pirep_xml.lonlat from zoa_sectors_basetop, west_pirep_xml, artcc
where (ST_DWithin(zoa_sectors_basetop.geom, west_pirep_xml.geom, 0)
and ST_DWithin(artcc.the_geom, zoa_sectors_basetop.geom, 0)) and
zoa_sectors_basetop.id='$i' and (west_pirep_xml.cld_base <= 5000 or
west_pirep_xml.cld_top <= 10000) and west_pirep_xml.cld_cvr != 'SKC'
and (zoa_sectors_basetop.type='LO' or
zoa_sectors_basetop.type='HILO');

So I'm not sure why this query is not working,

select distinct zoa_metar_xml.stn_id, zoa_metar_xml.metar_txt,
zoa_metar_xml.time, zoa_metar_xml.flt_cat, zoa_metar_xml.cld_cvr,
zoa_metar_xml.cld_base, zoa_metar_xml.lonlat from zoa_metar_xml,
zoa_sectors_basetop, artcc where (ST_DWithin
(zoa_sectors_basetop.geom, zoa_metar_xml.geom, 0) and ST_DWithin
(artcc.the_geom, zoa_sectors_basetop.geom, 0)) and
zoa_sectors_basetop.id='$i' and (zoa_sectors_basetop.type='LO' or
zoa_sectors_basetop.type='HILO');

Believe it has something to do with the ST_DWithin portion of the
query (but these work in other queries)...all of these queries are
being executed from a php file, then create kml files. The first query
creates kml file for metars, this is working and geometry is there, so
I'm not sure why I can't match these with the zoa_sectors_basetop.geom
or artcc.the_geom, because the last working query also works when
matching intersecting polygons with the zoa_sectors_basetop.geom. So
looks like the problem may lie in the geometry in the table
zoa_metar_xml. But can't figure why? Hope this is enough info, can
anyone help? Thanks,

Nick

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Yan Cheng Cheok 2010-01-29 00:56:50 Re: Primary Key Increment Doesn't Seem Correct Under Table Partition
Previous Message Pierre Chevalier 2010-01-29 00:15:53 Re: dynamic crosstab