<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7654.12">
<TITLE>Query for shapes completely within a circle</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->

<P><FONT COLOR="#000080" SIZE=2 FACE="Verdana">Using ST_DWithin(geom, geomPt, radius) returns all geom that 'intersects' any part of the circle's area (acts like ST_Intersects). </FONT></P>

<P><FONT COLOR="#000080" SIZE=2 FACE="Verdana">What I would like, however, is only those geom 'completely within the circle'. </FONT>

<BR><FONT COLOR="#000080" SIZE=2 FACE="Verdana">For instance, if the point is Orlando, FL and the radius is 2 miles, the ST_Dwithin would return a shapes like the state Florida and the whole US; where I only want the buildings in Orlando.</FONT></P>

<P><FONT COLOR="#000080" SIZE=2 FACE="Verdana">This is the closest approximation I have so far:</FONT>
</P>

<P><FONT COLOR="#000080" SIZE=2 FACE="Verdana">SELECT id, geom</FONT>

<BR><FONT COLOR="#000080" SIZE=2 FACE="Verdana">FROM geospatial</FONT>

<BR><FONT COLOR="#000080" SIZE=2 FACE="Verdana">WHERE ST_WITHIN(geom, ST_Expand(geometryFromText(geomPt, 4326), radius) )</FONT>
</P>

<P><FONT COLOR="#000080" SIZE=2 FACE="Verdana">This is much better, but it still returns some geom that are outside of the circle; specifically all geom completely within the superscribing box returned by ST_EXPAND.</FONT></P>

<P><FONT COLOR="#000080" SIZE=2 FACE="Verdana">Thanks for your help</FONT>

<BR><FONT COLOR="#000080" SIZE=2 FACE="Verdana">Tom</FONT>
</P>

</BODY>
</HTML>