This project is read-only.

NH.Spatial Postgis possible bug?

Sep 26, 2008 at 3:47 PM
Hello guys...
I´m trying to execute a "within" postgis function using NH.Spatial ...
The SQL that I need to get is something like that :

select nomemunicipio from tblcity m where within
( '0101000020C31000000000000000C049C06666666666E633C0', m.the_geom)

So, I created my City class/xml, with geom like that:
 <property name="Geometry" column="the_geom">
                         <param name="subtype">MULTIPOLYGON</param>
                         <param name="srid">4291</param>

That works great to load, insert ...

So, I execute that:

public IList FindByPoint(IPoint __point)
          IList results = Session.CreateCriteria(typeof(City))
               .Add(SpatialExpression.Within("Geometry", __point))
          return results;
And I always got a empty result...
The SQL generated was :

SELECT ... FROM tblCity this_ WHERE
ST_Within(this_.the_geom, :p0); :p0 =

It seems the ST_Within attributes was inverted... The geometry (p0)
needs to be the fisrt in function...
Is that corrected?

Ps,: I´m using trunk build...

Sep 26, 2008 at 7:48 PM
Edited Sep 26, 2008 at 7:58 PM
I think what you want to query is "City contains a point", so you sould use Contains instead of Within (ie. SpatialExpression.Contains(A,B) = "A contains B")