Geoserver learning note (6): Part 3 of Servlet and HTTP distribution process

Source: Internet
Author: User

Geoserver learning note (6): Part 3 of Servlet and HTTP distribution process

Su Weimin http://www.gisdev.cn/http://blog.csdn.net/suen/ Date:

All copyrights reserved. If you need to reprint the information, contact the author and indicate the source in a conspicuous position.

Followed by the geoserver learning notes (5): Servlet and HTTP dispatching process II (http://blog.csdn.net/suen/archive/2009/11/02/4759398.aspx ).

Response

The response is the processing of what is sent back to the user after their request. The format of this rsponse, for a getfeature request, is GML.

Here is an overview of the process in picture format:

Where it starts

At the very beginning, in wfsdispatcher, an httpserveletresponse is passed into doget () and dopost ()

public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException
 
public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException

Lets refer back to this digoal:

This response object is passed into the feature servelet, so it can be populated once it has a hold of a featurereader.

Output Strategy object

The output strategy object tells Geoserver how to proceede when returning the data. What does this mean? Here are some examples that are specified inWeb. xmlFile to help explain it:

 
    serviceStratagy
    
 
    SPEED
  

Why is it calledStrategy? A Strategy is a design pattern that is defined in the Gang of Four Design Patterns book (ISBN 0201633612 ). what it essential does, is allow the user to plug in their own method of specific Ming a specific task. so what Geoserver does is read the web. xml file, see what strategy you want to use ('speed' in our example), and plug it into the output response process.

You can define your own output strategy object by looking inOrg. vfny. geoserver. servlets. abstractservice. It must implementOrg. vfny. geoserver. servlets. abstractservice. servicestrategy

Here is a tutorial on setting up your own output strategy.

Feature streaming

Its very important to note that the Geoserver/Geotools design allows for Feature Streaming, meaning that Geoserver only ever has around one feature in memory at a time. this is very important for large queries (or you 'd run out of memory) as well as simutaneously doing multiple queries.

When a DataStore accepts a Query, it doesnt actually return Features, instead it returns a FeatureReader which can be used to read the Feature that the Query selects one-at-a-time. the delegate (ie. GML2 producer in our example) reads a single feature, converts it to GML2 and send the results off to the output Strategy object.

GML Encoding

After the output strategy has been determined, the Feature sends the output to a FeatureResponse object. This feature response object will then pass on the information to the GML2FeatureResponseDelegate object.

The GML encoding object will take care of the rest of the output for you that will be streamed through the output strategy.

The end

Notes

How datastores process query & Filter

Some DataStores (like the Database backed ones) can do most of the Filter processing in the database using the database's indexes. other datastores can do "quick" processing of certain components of the Filter. for example, the "normal shapefile" datastore can quickly do bounding-box tests for features. the "index shapefile" datastore (thats a shapefile with. qix spatial index file) can do spatial searching quickly.

Basically, the Filter object is sent to the datastore which looks at the Filter and beaks it into components:

  1. Portions that the datastore can index (ie. Quickly approximate a solution)
  2. Portions that the datastore can efficiently calculate (ie. quickly calculate a solution)
  3. Portions that the datastore cannot efficiently calculate (these will be handled by Geotools Java code)

All this is handled transparently by the datastore so the programmer just has to send a Query object off to the DataStore and not have to worry about how it processes it. the features returned by the FeatureReader will only be ones that pass the Filter conditions.

Lets looks at a PostGIS example for a Query's Filter that looks like this:

(The_geom INTERSECTS) AND (population & gt; 1000000)

This will be translated into the SQL query:

SELECT ... FROM 

     the_geom &&  -- this is the spatial index operation
 AND intersects(the_geom,  )      -- this is the full OGC spatial operation
 AND population > 1000000;

The same query to the "normal shapefile" datastore will be processed differently. The shapefile datastore can perform bounding-box vs bounding-box operations quickly because the shapefile has the bounding of each geometry stored.

The read processing is done in two states: (a) shapefile optimized and (B) Java-code handled.

foreach row in the shapefile
     If the row's bounding box overlaps the 
       THEN send this row to the next stage
       OTHERWISE this feature does not pass the Filter condition

Java code will then take the "approximate" solution that the datastore can quickly compute and fully evaluate the Filter.

The same query to the "indexed shapefile" datastore can be processed even more effiently. instead of having to read large portions of the shapefile to test every row to see if the bounding box intersects the search bounding box, it can just read a portion of the spatial index. java code will then take this "Approximate" solution that the datastore can very quickly compute and fully evaluate the filter.

(To be continued)

WhereHTTP distribution process after version 1.6

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.