<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.6000.16809" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=187572122-11032009>P.S. -- I meant Robert. Sorry I'm a bit out of it
today.</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=187572122-11032009></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=187572122-11032009>Thanks,</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=187572122-11032009>Regina</SPAN></FONT></DIV><FONT face=Arial
color=#0000ff size=2></FONT><FONT face=Arial color=#0000ff size=2></FONT><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> Paragon Corporation [mailto:lr@pcorp.us]
<BR><B>Sent:</B> Wednesday, March 11, 2009 6:21 PM<BR><B>To:</B> 'PostGIS Users
Discussion'<BR><B>Subject:</B> RE: [postgis-users] index-based
inconsistencies<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV dir=ltr align=left><SPAN class=718211022-11032009><FONT face=Arial
color=#0000ff size=2>Rick,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=718211022-11032009><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=718211022-11032009><FONT face=Arial
color=#0000ff size=2>Which version of PostgreSQL were you running when you
loaded this data? I think I may have ran into similar issues with an
earlier point version of 8.3</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=718211022-11032009><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=718211022-11032009><FONT face=Arial
color=#0000ff size=2>The problem was that the stored BBOx was wrong. To
verify if this is the issue, do the following</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=718211022-11032009><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=718211022-11032009><FONT face=Arial
color=#0000ff size=2>SELECT ST_Box2D(the_geom) As the_wrongbbox,
ST_Box2D(ST_AsBinary(the_geom)) As the_rightbbox, ST_Box3D(the_geom) As
the_right3dBox</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=718211022-11032009><FONT face=Arial
color=#0000ff size=2>FROM counties</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=718211022-11032009><FONT face=Arial
color=#0000ff size=2>WHERE NOT (ST_Box2D(the_geom) =
ST_Box2D(ST_AsBinary(the_geom)) )</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=718211022-11032009><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=718211022-11032009><FONT face=Arial
color=#0000ff size=2>If you get answers to the above, then that is the
culprit</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=718211022-11032009><FONT face=Arial
color=#0000ff size=2></FONT></SPAN><SPAN class=718211022-11032009><BR><FONT
face=Arial color=#0000ff size=2>I think to fix I ended up doing a </FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff
size=2></FONT> </DIV>
<DIV dir=ltr align=left></SPAN><SPAN class=718211022-11032009><FONT face=Arial
color=#0000ff size=2>ST_DropBBOx(the_geom) on all those that didn't match
the calculated and then </FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=718211022-11032009><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=718211022-11032009><FONT face=Arial
color=#0000ff size=2>ST_AddBBOX(the_geom) on all those where
ST_HasBBOX(the_geom) = false</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=718211022-11032009><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=718211022-11032009><FONT face=Arial
color=#0000ff size=2>So </FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=718211022-11032009><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=718211022-11032009><FONT face=Arial
color=#0000ff size=2>UPDATE counties SET the_geom =
ST_DropBBOX(the_geom)</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=718211022-11032009><FONT face=Arial
color=#0000ff size=2><SPAN class=718211022-11032009><FONT face=Arial
color=#0000ff size=2>WHERE NOT (ST_Box2D(the_geom) =
ST_Box2D(ST_AsBinary(the_geom)) );</FONT></SPAN></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=718211022-11032009><FONT face=Arial
color=#0000ff size=2><SPAN
class=718211022-11032009></SPAN></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=718211022-11032009><FONT face=Arial
color=#0000ff size=2><SPAN class=718211022-11032009>UPDATe countries SET
the_geom = ST_AddBBOX(the_geom)</SPAN></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=718211022-11032009><FONT face=Arial
color=#0000ff size=2><SPAN class=718211022-11032009>WHERE ST_HasBBOx(the_geom) =
false;</SPAN></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=718211022-11032009><FONT face=Arial
color=#0000ff size=2><SPAN
class=718211022-11032009></SPAN></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=718211022-11032009><FONT face=Arial
color=#0000ff size=2><SPAN class=718211022-11032009>Hope that
helps,</SPAN></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=718211022-11032009><FONT face=Arial
color=#0000ff size=2><SPAN
class=718211022-11032009>Regina</SPAN></FONT></SPAN></DIV>
<DIV dir=ltr align=left>
<HR tabIndex=-1>
</DIV>
<DIV dir=ltr align=left><FONT face=Tahoma size=2><B>From:</B>
postgis-users-bounces@postgis.refractions.net
[mailto:postgis-users-bounces@postgis.refractions.net] <B>On Behalf Of
</B>Robert Hollingsworth<BR><B>Sent:</B> Wednesday, March 11, 2009 4:55
PM<BR><B>To:</B> postgis-users<BR><B>Subject:</B> [postgis-users] index-based
inconsistencies<BR></FONT><BR></DIV>
<DIV></DIV>
<TABLE cellSpacing=0 cellPadding=0 border=0>
<TBODY>
<TR>
<TD vAlign=top>using postgresql 8.3.4<BR>using postgis 1.3.3<BR>using geos
3.0.0<BR>using proj 4.6.1<BR><BR>I'm encountering a couple of oddities
which I'm pretty sure are related.<BR><BR>I have US Census Congressional
districts modeled in PostGIS.<BR><BR>I've got a simple php program that
uses ST_Within( ) to check a lat,lon against the congressional district
polygons. A small number of the districts are causing the query to
return zero records incorrectly.<BR><BR>I've also got a simple
php-mapscript with a LAYER to simply display all of these congressional
districts. When zoomed out around 1:400k and further out, these
peculiar districts appear along side their neighbors. When I zoom in
closer, these same districts stop appearing.<BR><BR>I'm pretty sure this
is a problem with the spatial indexes, which were created by shp2pgsql,
because I converted the search program from ST_Within( ) to _ST_Within( ),
which is advertised as skipping the indexing. _ST_Within( ) is a bit
slower, but finds these districts ok.<BR><BR>I've run VACUUM ANALYZE on
the table, but this hasn't changed anything.<BR><BR>I haven't dug into the
mapserver pg driver to see if there is any way for me to manipulate the
generated query into skipping indexes.<BR><BR>I haven't yet dug into the
records further to see if they have pathological bboxes or
similar.<BR><BR>There are no holes in these polygons.<BR><BR>Anyone have
any ideas on this?<BR><BR>thanks,<BR>Robert
H.<BR></TD></TR></TBODY></TABLE></BODY></HTML>