Frank Warmerdam schrieb:
Tom Kazimiers wrote:
Hello,
can you tell me how the MapServer deals with vector data? I mean what
happens after a Request?
E.g.: If file not already open, the file is opened, a quadtree is
build and the request is performed on the quadtree data and no
further file reading is required.
Tom,
This is a very broad question. The definition of what MapServer does
is in
the source. But I'll try to give a wee bit of information. I'll address
this in the context of a WMS GetMap request with vector layers from
shapefiles.
1) The map file to be used is identified, and parse into a mapObj.
2) The request parameters are parsed and used to manipulate the mapObj
state.
(turning layers on/off, setting the region and resolution, etc)
3) Each "on" layer is rendered in turn in msDrawLayer().
4) For vector layers, the layer is "opened" which basically means the
associated data files are opened. In normal use vector file handles are
not kept open from request to request (since each request is a new cgi
invocation) and not even from layer to layer in the same map draw. So
called "connection caching" in a fastcgi situation is an exception to the
rule. For shapefiles this open results in opening the .shp, .shx, .dbf
and .qix if there is one.
5) The draw function loops through asking for shapes from the shapefile
code. If there is a .qix file, mapserver will use it and the spatial
extent to figure out the shape indices to load. (actually, I think it may
do this in one complete pass and then sort the indices rather than doing
it on an ongoing basis).
6) each shape is drawn. Note that the in-memory representation (a
shapeObj)
normally only lives long enough to be drawn and is freed before the next
features is read.
7) the layer is closed, and all associated files are closed.
NOTE: there is no in-memory quadtree built. If a qix (spatial index
using
quadtrees) exists on disk it is used, otherwise all features are
scanned and
compared to the spatial and attribute filters. I think there is some
short
circuiting of the shape reading to first look at the shape extent before
processing the rest of the shape.
Particulars vary based on the file type, the kind of request made, and
various other circumstances. I'm also likely a bit off on some low level
details. But hopefully this is a helpful response to what I claim is
a vague
question!
Best regards,
Frank,
thank you for your quick response. This is what I wanted to read indeed.
I did also take a look at the source, found also msdraw.c but somehow
missed orientation :)
This (vague) question came up by thinking about how I can change a tool
I have written which is basically a GIS application for PDAs in way that
I can for example identify single features of a shapefile (since
currently I only draw them without making constraints like attributes
available).
Do you think that if MapServer would be a whole GIS application on its
own and no "server" and has only to deal with about 20 maps or so it
would also do displaying like it is done now? Or could it be that in
this case the opening and closing of files would be too slow compared to
an in-memory quadtree for example?
Thanks again
Tom