<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Hi list,<br>
<br>
I recently came across a problem with the order features are
rendered by Mapserver. I am displaying road surveys done at various
times, and have a WMS layer that displays the latest survey results.
Rather than trying to do complicated segmentation, I simply display
features ordered by survey date, with the most recent records on
top. <br>
<br>
Initially my layer DATA clause was similar to the following:<br>
<br>
SELECT ID, GEOM, Rating, YEAR([TimeStamp]) AS [YEAR] from mydata)
as tbl USING UNIQUE ID USING SRID=29902 ORDER BY [TimeStamp] DESC<br>
<br>
I hadn't realised that anything outside after the USING... statement
was ignored, so the records were displayed unordered. <br>
<br>
I then tried using:<br>
<br>
SELECT ID, GEOM, Rating, YEAR([TimeStamp]) AS [YEAR] from mydata
ORDER BY [TimeStamp] DESC) as tbl USING UNIQUE ID USING SRID=29902<br>
<br>
However when the data for the WMS is prepared this SQL becomes a
subquery, and a WHERE clause is added to get the data for the
requested extent. <br>
SQL Server doesn't allow ORDER BY in a subquery, so an error is
thrown:<br>
<br>
"The ORDER BY clause is invalid in views, inline functions,
derived tables, subqueries, and common table expressions, unless TOP
or FOR XML is also specified."<br>
<br>
My current workaround is to change the SQL to:<br>
<br>
SELECT TOP 1000000 ID, GEOM, Rating, YEAR([TimeStamp]) AS [YEAR]
from mydata ORDER BY [TimeStamp] DESC) as tbl USING UNIQUE ID USING
SRID=29902<br>
<br>
However this causes slow queries as all data needs to be fetched in
order before filtering. <br>
<br>
So my question is is there a way to order records using another
LAYER property (similar to the FILTER property), so ordering is done
only on the records returned for rendering?<br>
<br>
Thanks for any advice,<br>
<br>
Seth<br>
<br>
<div class="moz-text-html" lang="x-western"> <font color="#888888">--<br>
web:</font><a href="http://geographika.co.uk"><font
color="#888888"> </font>http://geographika.co.uk</a><br>
<font color="#888888">twitter: @geographika<br>
</font><br>
</div>
<br>
</body>
</html>