[mapserver-dev] Difference between queryByRect and queryByShape

Steve Lime sdlime at gmail.com
Wed Jul 27 22:26:38 EDT 2011


What version? Can you produce a simple test case? Any reprojection going on? -Steve

Sent from my iPad

On Jul 27, 2011, at 5:11 AM, dragoncino <dragoncino at yahoo.it> wrote:

> Hello,
> I'm trying to implement some query routines using C# and MapScript. I have
> discovered that there is a difference between the number of shapes resulted
> from the methods queryByRect and queryByShape (obviously using a rectangle
> as shape), so I think I'm doing something wrong.
> Here is the code I used:
> 
>            public void QueryTest()
>            {
>                mapObj map = new mapObj(@"C:\temp\mymap.map");
> 
>                layerObj layer = map.getLayerByName("streets");
>                rectObj r = new rectObj(12.6478, 42.5636, 12.6488, 42.5642,
> 0);
> 
>                int error = layer.queryByRect(map, r);
>                if (error != 0) throw new Exception("Invalid query");
> 
>                resultCacheObj results1 = layer.getResults();
>                int i1 = results1.numresults;
>                ///i1 == 4
> 
>                shapeObj shp = new shapeObj(2);
>                lineObj line = new lineObj();
>                line.add(new pointObj(r.minx, r.miny, 0, 0));
>                line.add(new pointObj(r.minx, r.maxy, 0, 0));
>                line.add(new pointObj(r.maxx, r.maxy, 0, 0));
>                line.add(new pointObj(r.maxx, r.miny, 0, 0));
>                shp.add(line);
> 
>                error = layer.queryByShape(map, shp);
>                if (error != 0) throw new Exception("Invalid query");
> 
>                resultCacheObj results2 = layer.getResults();
>                int i2 = results2.numresults;
>                ///i2 == 7 != i1
>            }
> 
> Thanks in advance for anyone that can clear up this mystere.
> 
> 
> --
> View this message in context: http://osgeo-org.1803224.n2.nabble.com/Difference-between-queryByRect-and-queryByShape-tp6625562p6625562.html
> Sent from the Mapserver - Dev mailing list archive at Nabble.com.
> _______________________________________________
> mapserver-dev mailing list
> mapserver-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-dev


More information about the mapserver-dev mailing list