mapscript query question (oracle related)
Fernando Simon
fsimon at UNIVALI.BR
Fri Jan 27 03:14:06 PST 2006
Hi Christopher,
This issue is related with the rownum in your data definition. The
UNIQUE parameter accepts only number, usually the primary key for the
table. The problem with rownum is because it's returns a sequence for
the number of the rows returned, but it's not a real identifier for the
row because it's can change.
The maporaclespatial driver uses the UNIQUE to get the unique identifier
for the row, but not rownum, because inside of the source code the
function that retrieve the identifier and query for the non-spatial data
is different functions. So if you use the rownum the return will be only
one.
Best regards.
------------------------------------------------------------------------
Fernando Simon
Mapserver and Oracle Spatial developer
G10 - Laboratorio de Computacao Aplicada - Brazil
http://www.univali.br/g10 - UNIVALI/CTTMAR
------------------------------------------------------------------------
Christopher Condit wrote:
>
> Ok – I finally got the C# MapScript query functionality to work (see
> below) – sort of…
>
> I can query raster layers wonderfully – everything works as
> advertised. However, when I attempt to query the Oracle layer that
> appears below, I always get the same one result back – no matter what
> lat/lon I use for my pointObj. The result I get back was the first
> query I tested, which makes me suspicious. Is there something special
> I need to do for an Oracle query?
>
> mapObj map = new mapObj(@"session.map");
>
> layerObj myLayer = map.getLayerByName("mylayer");
>
> myLayer.queryByPoint(map, new pointObj(-77.0, 18.0, 0, 0),
> mapscript.MS_MULTIPLE, 1.0 );
>
> myLayer.open();
>
> for (int i = 0; i < myLayer.getNumResults(); i++)
>
> {
>
> resultCacheMemberObj result = myLayer.getResult(i);
>
> shapeObj shape = myLayer.getFeature(result.shapeindex, result.tileindex);
>
> for (int j = 0; j < shape.numvalues; j++)
>
> System.Console.Write(shape.getValue(j) + " ");
>
> System.Console.WriteLine("");
>
> }
>
> obisLayer.close();
>
> ------------------------------------------------------------------------
>
> *From:* UMN MapServer Users List
> [mailto:MAPSERVER-USERS at lists.umn.edu] *On Behalf Of *Christopher Condit
> *Sent:* Thursday, January 19, 2006 11:15 AM
> *To:* MAPSERVER-USERS at lists.umn.edu
> *Subject:* [UMN_MAPSERVER-USERS] mapscript query question
>
> I’m using C# MapScript to build my MapFile. This is working great. Now
> I want to query the MapFile programmatically – but can’t seem to
> figure out how to do it. Is there a tutorial that I’m not seeing?
>
> Here’s my code snippet:
>
> layerObj queryLayer = map.getLayerByName("myLayer");
>
> if (null != queryLayer)
>
> {
>
> int count = queryLayer.queryByPoint(myMap, new pointObj(-82, 25, 0,
> 0), mapscript.MS_MULTIPLE, 5.0d);
>
> if (count > 0)
>
> {
>
> queryLayer.open();
>
> for (int i = 0; i < count; i++)
>
> {
>
> resultCacheMemberObj result = queryLayer.getResult(i);
>
> shapeObj shape = obisLayer.getFeature(result.shapeindex,
> result.tileindex);
>
> }
>
> queryLayer.close();
>
> }
>
> }
>
> The resultCacheMemberObj never gets a value, even when query by point
> returns > 0. Here’s my layer definition:
>
> LAYER
>
> CONNECTION "user/pass"
>
> CONNECTIONTYPE ORACLESPATIAL
>
> DATA "SHAPE FROM (SELECT * FROM MYTABLE WHERE NAME LIKE 'S%') USING
> UNIQUE ROWNUM"
>
> DUMP TRUE
>
> METADATA
>
> "wfs_title" "SimpleWFSTest"
>
> "gml_include_items" "all"
>
> END
>
> NAME "myLayer"
>
> PROJECTION
>
> "init=epsg:4326"
>
> END
>
> SIZEUNITS PIXELS
>
> STATUS DEFAULT
>
> TOLERANCEUNITS PIXELS
>
> TRANSPARENCY 100
>
> TYPE POINT
>
> UNITS DD
>
> CLASS
>
> METADATA
>
> END
>
> STYLE
>
> ANGLE 360
>
> COLOR 255 0 0
>
> OUTLINECOLOR 0 255 0
>
> SIZE 8
>
> SYMBOL "circle"
>
> END
>
> END
>
> END
>
> Thanks,
>
> Chris
>
More information about the MapServer-users
mailing list