[mapserver-dev] Difference between queryByRect and queryByShape

dragoncino dragoncino at yahoo.it
Wed Jul 27 06:11:37 EDT 2011


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.


More information about the mapserver-dev mailing list