More OracleSpatial queryByAttributes

Hallgren Johan E jhhal at WMDATA.COM
Fri Mar 30 16:39:31 EDT 2007


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/20070330/75a6f39d/attachment.html


More information about the mapserver-dev mailing list