More OracleSpatial queryByAttributes
Hallgren Johan E
jhhal at WMDATA.COM
Sat Mar 31 01:37:57 EDT 2007
I think I found the error myself
I have to have the "USING UNIQUE objected" in the string, otherwise the
functions will return wrong shapeindex.
I also have to place the NONE parameter at the correct place in the
string (NONE tells mapserver to not use any Spatial operator and it will
be fast when querying). As I have found out, the datastring should be
USING UNIQUE objectid NONE VERSION 10g when doing QueryByAttribute with
good performance.
The only change I should prefer here is to change the OracleSpatial
interface so the order wasn't so important. Why not "USING UNIQUE
objectid FUNCTION NONE VERSION 10g"
/Johan
___________________________________
Johan Hallgren
WM-data a LogicaCMG company
Pelle Bergs backe 3
Box 1938, 791 19 Falun
Tel: 023-547 46 (int: +46-2354746)
Mobil: 070-588 44 28 (int: +46-705884428)
johan.e.hallgren at wmdata.com
<BLOCKED::mailto:johan.e.hallgren at wmdata.com>
http://www.wmdata.se
<BLOCKED::/exchweb/bin/redir.asp?URL=http://www.wmdata.se/>
________________________________
From: UMN MapServer Developers List [mailto:MAPSERVER-DEV at LISTS.UMN.EDU]
On Behalf Of Hallgren Johan E
Sent: den 30 mars 2007 22:40
To: MAPSERVER-DEV at LISTS.UMN.EDU
Subject: [UMN_MAPSERVER-DEV] More OracleSpatial queryByAttributes
I have tested more to isolate the problem.
Here is the MapFile
LAYER
NAME SDOLayer
TYPE POLYGON
STATUS OFF
CONNECTION "user/pwd at tnsname"
CONNECTIONTYPE oraclespatial
DATA "shape FROM SDOLayer USING UNIQUE objectid VERSION 10g"
TEMPLATE "c:\temp\template.txt"
STATUS DEFAULT
MAXSCALE 150000
DEBUG ON
CLASS
STYLE
OUTLINECOLOR 0 0 255
COLOR 255 0 0
END
END
END
Here is a samplecode.
mapObj mapObj = new
mapObj(@"C:\Project\applications\GMS\GMSAgent\MapFiles\Map.map");
layerObj oLayerObj = mapObj.getLayerByName("SDOLayer");
string orgDataStr = oLayerObj.data;
string tmpDataStr = oLayerObj.data;
int iUsingLocation = tmpDataStr.LastIndexOf(" USING ");
if (iUsingLocation > 0)
tmpDataStr = orgDataStr.Substring(0, iUsingLocation);
tmpDataStr += " USING NONE";
// CREATE ERROR.
// This is used to speed up the query, no spatial operator will be used.
oLayerObj.data = tmpDataStr;
string strFld = "OBJECTID";
string strWhere = "OBJECTID = 2000";
oLayerObj.queryByAttributes(mapObj, strFld, strWhere,
mapscript.MS_MULTIPLE);
oLayerObj.data = orgDataStr;
resultCacheObj oResultCacheObj = oLayerObj.getResults();
if (oResultCacheObj.numresults > 0)
{
int lFeat = 0;
oLayerObj.open();
for (lFeat = 0; lFeat < oResultCacheObj.numresults; lFeat++)
{
resultCacheMemberObj oResultCacheMemberObj =
oResultCacheObj.getResult(lFeat);
// ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR -
ERROR - ERROR
// HERE IS THE ERROR.
// oResultCacheMemberObj.shapeindex will always return the first
record. If the oLayerObj.data
// is not changed, the result is correct but the perforamce is
terrible.
shapeObj oShapeObj =
oLayerObj.getFeature(oResultCacheMemberObj.shapeindex,
oResultCacheMemberObj.tileindex);
for (int item = 0; item < oLayerObj.numitems; item++)
{
string strUFldName = oLayerObj.getItem(item).ToUpper();
if (strUFldName != "SHAPE")
{
string strVal = oShapeObj.getValue(item);
System.Diagnostics.Debug.Write(strUFldName + "=" + strVal + ",
");
}
}
System.Diagnostics.Debug.Write(Environment.NewLine);
System.Diagnostics.Debug.WriteLine("-------------------");
}
oLayerObj.close();
}
___________________________________
Johan Hallgren
WM-data a LogicaCMG company
Pelle Bergs backe 3
Box 1938, 791 19 Falun
Tel: 023-547 46 (int: +46-2354746)
Mobil: 070-588 44 28 (int: +46-705884428)
johan.e.hallgren at wmdata.com
<BLOCKED::mailto:johan.e.hallgren at wmdata.com>
http://www.wmdata.se
<BLOCKED::/exchweb/bin/redir.asp?URL=http://www.wmdata.se/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-dev/attachments/20070331/caf1fb59/attachment.html
More information about the mapserver-dev
mailing list