getFeature problem with C# MapScript
Zhonghai Wang
zhonghaiw at GMAIL.COM
Mon Aug 14 02:24:22 PDT 2006
Hi there,
I am trying to get the shape objects with the function
getFeature(shapeindex,tileindex), but it seems that the layer can not be
opened for getFeature function, here is the source code:
Public Function getShapeFromLayer(ByVal aryQueryExt As Array, ByVal objLayer
As layerObj, _
ByVal objParentMap As mapObj) As shapeObj
' get all the shape objects within the aryQueryExt specified area,
' where the values should be geographic coordinates,
' the format should be ayrQueryExt(XMin, YMin, XMax, YMax)
Try
Dim tempRect As New rectObj(aryQueryExt(0), aryQueryExt(1), aryQueryExt(2),
aryQueryExt(3), 0)
' indicate the success or failure
Dim intQuery As Integer
Dim tempShape As shapeObj = Nothing
intQuery = objLayer.queryByRect(objParentMap, tempRect)
' open the layer to get features
If intQuery = 1 Then
Dim intOpen As Integer
intOpen = objLayer.open()
Dim resultMem As resultCacheMemberObj = Nothing
resultMem = objLayer.getResult(intQuery)
tempShape = objLayer.getFeature(resultMem.shapeindex, resultMem.tileindex)
objLayer.close()
End If
Return tempShape
Catch ex As Exception
Throw New Exception("failed to get Features from the Layer!", ex)
End Try
End Function
the intQuery value is 1, means that the query is successful, but the intOpen
is always 0, seems that the layer can not be opened for getFeature function.
The layer queried is a memory layer created with a function on the fly, I
don't know if this is a problem for the getFeature function.
the scenario of this function in my application is:
a new layer is created on the fly with the data from the Oracle Spatial
database when the first user request comes in, and this layer will be always
the same through out a user session, so I am trying to get the shape objects
from the layer and store them into a data table, so that I can create a new
layer with these shape objects without connection with the oracle spatial
database any more, and this may improve the mapserver performance, since I
do not need to access the database anymore every time when a new map image
is needed to be rendered.
and the shape object in the queried layer may be a point or a polygon.
BTW: the map extent unit of the map object is meter, but the queried layer
has decimal degree (WGS84 layer) as map unit, but the values of the query
rectangle is also in degree unit, I don't know if this will cause the
getFeature problem. Just for info.
thanks for any clues to solve this problem.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20060814/01c90550/attachment.htm>
More information about the MapServer-users
mailing list